#-*- coding: latin-1 -*-
'''
Created on 31.10.2013

@author: Hualiang Qi
'''
import unittest
from arabic2roman import arabic_to_roman
from converterexception import ArabicTooBigException, ArabicInvalidException


class ArabicToRomanBaseNumberTest(unittest.TestCase):

    def test_1_I(self):
        self.assertEquals(arabic_to_roman(1), "I", "Arabic 1 must be converted to Roman I")

    def test_5_V(self):
        self.assertEquals(arabic_to_roman(5), "V", "Arabic 5 must be converted to Roman V")

    def test_10_X(self):
        self.assertEquals(arabic_to_roman(10), "X", "Arabic 10 must be converted to Roman X")


class ArabicToRomanOneDigitTest(unittest.TestCase):

    def test_2_II(self):
        self.assertEquals(arabic_to_roman(2), "II", "Arabic 2 must be converted to Roman II")

    def test_3_III(self):
        self.assertEquals(arabic_to_roman(3), "III", "Arabic 3 must be converted to Roman III")

    def test_4_IV(self):
        self.assertEquals(arabic_to_roman(4), "IV", "Arabic 4 must be converted to Roman IV")

    def test_6_VI(self):
        self.assertEquals(arabic_to_roman(6), "VI", "Arabic 6 must be converted to Roman VI")

    def test_7_VII(self):
        self.assertEquals(arabic_to_roman(7), "VII", "Arabic 7 must be converted to Roman VII")

    def test_8_VIII(self):
        self.assertEquals(arabic_to_roman(8), "VIII", "Arabic 8 must be converted to Roman VIII")

    def test_9_IX(self):
        self.assertEquals(arabic_to_roman(9), "IX", "Arabic 9 must be converted to Roman IX")


class ArabicToRomanTwoDigitsTest(unittest.TestCase):

    def test_11_II(self):
        self.assertEquals(arabic_to_roman(11), "XI", "Arabic 11 must be converted to Roman XI")

    def test_14_XIV(self):
        self.assertEquals(arabic_to_roman(14), "XIV", "Arabic 14 must be converted to Roman XIV")

    def test_16_XVI(self):
        self.assertEquals(arabic_to_roman(16), "XVI", "Arabic 16 must be converted to Roman XVI")

    def test_19_XIX(self):
        self.assertEquals(arabic_to_roman(19), "XIX", "Arabic 19 must be converted to Roman XIX")

    def test_40_XL(self):
        self.assertEquals(arabic_to_roman(40), "XL", "Arabic 40 must be converted to Roman XL")

    def test_90_XL(self):
        self.assertEquals(arabic_to_roman(90), "XC", "Arabic 90 must be converted to Roman XC")

class ArabicToRomanFourDigitsTest(unittest.TestCase):

# http://en.wikipedia.org/wiki/Roman_numerals
#     1954 as MCMLIV (Trailer for the movie The Last Time I Saw Paris)[7]
#     1990 as MCMXC (The title of musical project Enigma's debut album MCMXC a.D., named after the year of its release.)
#     2008 as MMVIII - the year of the games of the XXIX (29th) Olympiad (in Beijing)
    def test_1954_MCMLIV(self):
        self.assertEquals(arabic_to_roman(1954), "MCMLIV", "Arabic 1954 must be converted to Roman MCMLIV")

    def test_1990_MCMXC(self):
        self.assertEquals(arabic_to_roman(1990), "MCMXC", "Arabic 1990 must be converted to Roman MCMXC")

    def test_2008_MMVIII(self):
        self.assertEquals(arabic_to_roman(2008), "MMVIII", "Arabic 2008 must be converted to Roman MMVIII")


class SpecialCasesTest(unittest.TestCase):
    def test_too_big_arabic_number(self):
        self.assertRaises(ArabicTooBigException, arabic_to_roman, 4000)

    def test_invalid_arabic_number(self):
        self.assertRaises(ArabicInvalidException, arabic_to_roman, "N/A")

    def test_arabic_number_zero(self):
        self.assertRaises(ArabicInvalidException, arabic_to_roman, 0)


if __name__ == "__main__":
    unittest.main()